package com.zc.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zc.domain.DoubleListData;
//import com.zc.service.DataService;
import com.zc.service.FaultService;
import com.zc.service.PowerFactorService;
import com.zc.service.PowerService;
import com.zc.service.PresService;
import com.zc.service.TcService;
import com.zc.service.TemService;
import com.zc.service.ElecService;
import com.zc.service.RedisService;

@Controller
public class ElecController {
	@Autowired
	private ElecService elecService;
	@Autowired
	private RedisService redisService;
	
	@RequestMapping(value = "/getElec",method = RequestMethod.POST)
    public @ResponseBody DoubleListData getElec(){
		String key="elecData";
		DoubleListData elecData=null;
		if(redisService.hasKey(key)){
			elecData=(DoubleListData) redisService.get(key);
		}		
		else {
			elecData=elecService.getElec();
			redisService.set(key, elecData);
		}
		return elecData;
    }
	
	@RequestMapping(value = "/getTodayElec",method = RequestMethod.POST)
    public @ResponseBody DoubleListData getTodayElec(){
		return elecService.getTodayElec();
    }
	
	@RequestMapping(value = "/getMonthElec",method = RequestMethod.POST)
    public @ResponseBody DoubleListData getMonthElec(){
		return elecService.getMonthElec();
    }
	
	@RequestMapping(value = "/getYearElec",method = RequestMethod.POST)
    public @ResponseBody DoubleListData getYearElec(){
		return elecService.getYearElec();
    }
	
	@RequestMapping(value = "/daySelect",method = RequestMethod.POST)
    public @ResponseBody DoubleListData daySelect(@RequestParam("date") String date){
		return elecService.daySelect(date);
    }
	
	@RequestMapping(value = "/monthSelect",method = RequestMethod.POST)
    public @ResponseBody DoubleListData monthSelect(@RequestParam("date") String date){
		return elecService.monthSelect(date);
    }
	
	@RequestMapping(value = "/yearSelect",method = RequestMethod.POST)
    public @ResponseBody DoubleListData yearSelect(@RequestParam("date") String date){
		return elecService.yearSelect(date);
    }
}
